<template>
	<view class="count">
		<view class="topTabs">
			<view class="topOne f f-a-c">
				<view v-for="(item,index) in list" @click="topT(item,index)" :key="index"
					:class="{active:index==indexs}" class="children">
					{{item.name}}
				</view>
			</view>
			<view class="topOne f f-a-c m-t-25">
				<view v-for="(item,index) in botList" @click="topB(item,index)" :key="index" :class="{act:index==ind}"
					class="ageSui">
					{{item.name}}
				</view>
			</view>
		</view>
		<!-- 下面的列表 -->
		<view v-if="dataList.length" class="botBody p-20">
			<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onreachBottom">
				<view v-for="(item,index) in dataList" :key="index" class="itemBox p-20 b-r-15 b-f m-b-20">
					<view class="testName">
						{{item.name}}
					</view>
					<view class="time m-t-10">
						创建时间: {{item.created_at}}
					</view>
					<view class="btn f f-j-f-e m-t-10">
						<view @click="assess(item)" class="evaluation">
							开始测评
						</view>
					</view>
				</view>

			</scroll-view>
		</view>
		<view v-else class="zanwu">
			暂无数据
		</view>
		<!-- 规则提示 -->
		<image @click="evaluation_rule" src="/static/guize.png" class="rulePrompt" mode=""></image>
		<image src="/static/ceshi.png" @click="testCecord" class="rulePromptCeshi" mode=""></image>
		<u-mask :show="show">
			<view class="center">
				<image src="/static/login/bg.png" class="bg" mode=""></image>
				<view class="gize">
					<image src="/static/cha.png" @click="show=false" class="cha" mode=""></image>
					<view class="tishi">
						规则及提示
					</view>
					<view class="xuanze">
						请认真选择类型，如实答题，保持自己信用度！
					</view>
				</view>
			</view>
		</u-mask>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: true,
				indexs: 0,
				ind: 0,
				botList: [{
					name: '0~3岁'
				}, {
					name: '0~3岁'
				}, {
					name: '0~3岁'
				}, {
					name: '0~3岁'
				}, {
					name: '0~3岁'
				}, {
					name: '0~3岁'
				}],
				list: [],
				topList: [{
					name: '少儿阅读'
				}, {
					name: '课外阅读'
				}, {
					name: '科普读物'
				}, {
					name: '科普读物'
				}, {
					name: '科普读物'
				}, {
					name: '科普读物'
				}, {
					name: '科普读物'
				}, {
					name: '科普读物'
				}, {
					name: '科普读物'
				}, {
					name: '科普读物'
				}],
				oneId: '',
				towId: '',
				page: 1,
				dataList: [],
				toal: 0
			}
		},
		onShow() {
			this.initFen()
		},
		watch: {

		},
		methods: {
			evaluation_rule() {
				uni.navigateTo({
					url: '/pageC/detils?name=evaluation_rule'
				})
			},
			// 这个是获取分类列表
			async initFen() {
				let n = await this.$api.Categories()
				this.list = n.data.categories
				this.botList = this.list[0].children
				this.oneId = this.list[0].id
				this.towId = this.list[0].children[0].id
				// 请求列表接口
				this.initList()
			},
			// 这个是品测列表
			async initList() {
				let n = await this.$api.Subjects({
					page: this.page,
					a_category_id: this.oneId,
					b_category_id: this.towId
				})
				// 总页数
				this.toal = n.data.total
				if (this.dataList.length < this.toal) {
					this.dataList = [...this.dataList, ...n.data.data]
				} else {
					this.dataList = n.data.data
				}
			},
			// 点击去测评记录
			testCecord() {
				uni.navigateTo({
					url: '/pages/ReadingParty/TestCecord'
				})
			},
			// /点击开始测评
			assess(item) {
				uni.navigateTo({
					url: '/pages/ReadingParty/StartAssessment?id=' + item.id
				})
			},
			//这个是列表
			onreachBottom() {
				this.page++
				this.initList()
				// console.log('123456');
			},
			// 这个是最上面的
			topT(item, index) {
				this.indexs = index
				this.botList = item.children
				this.oneId = item.id
				if (item.children[0]) {
					this.towId = item.children[0].id
				} else {
					this.towId = ''
				}
				this.page = 1
				this.dataList = []
				this.initList()
			},
			// 这个是岁数筛选
			topB(item, index) {
				this.ind = index
				this.towId = item.id
				this.dataList = []
				this.initList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zanwu {
		font-size: 36rpx;
		font-weight: 600;
		position: absolute;
		top: 50%;
		left: 50%;
		color: #c7c3c3;
		transform: translate(-50%, -50%);
	}

	.center {
		position: absolute;
		width: 70%;
		border-radius: 20rpx;
		height: 602rpx;
		// background-color: pink;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);

		.bg {
			position: absolute;
			border-radius: 20rpx;
			width: 100%;
			border-radius: 20rpx;
			height: 602rpx;
			// background-color: pink;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);

		}

		.gize {
			position: relative;
			width: 100%;
			height: 100%;
			z-index: 999999999999999;

			.cha {
				position: absolute;
				width: 48rpx;
				height: 48rpx;
				bottom: -0rpx;
				left: 50%;
				transform: translateX(-50%);
			}
		}

		.tishi {
			font-size: 32rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			text-align: center;
			color: #ffffff;
			margin: 40rpx 0;
			margin-top: 100rpx;
		}

		.xuanze {
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			text-align: center;
			color: #ffffff;
			padding: 0 50rpx;
		}
	}

	.rulePrompt {
		position: fixed;
		bottom: 300rpx;
		width: 140rpx;
		height: 140rpx;
		right: 20rpx;
	}

	.rulePromptCeshi {
		position: fixed;
		bottom: 170rpx;
		width: 140rpx;
		height: 140rpx;
		right: 20rpx;
	}

	.evaluation {
		width: 146rpx;
		height: 56rpx;
		line-height: 55rpx;
		border: 2rpx solid #009d85;
		border-radius: 30rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #009d85;
	}

	.time {
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC-Medium;
		font-weight: 500;
		color: #999999;
	}

	.testName {
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		color: #333333;
	}

	.children {
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: left;
		color: #999999;
		margin-right: 40rpx;
		// flex-basis: 112rpx;
		flex-shrink: 0;
	}

	.itemBox {
		width: 100%;
	}

	.ageSui {
		padding: 5rpx 10rpx;
		background: #f8f8f8;
		border-radius: 26rpx;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #999999;
		flex-shrink: 0;
		margin-right: 30rpx;
	}

	.topOne {
		overflow-x: auto;
	}

	.topOne::-webkit-scrollbar {
		display: none
	}

	.botBody {
		height: calc(100vh - 166rpx);
		width: 100%;
		// background-color: pink;
		overflow-y: auto;
	}

	.act {
		background: #009d85;
		color: #ffffff;
	}

	.active {
		font-size: 32rpx;
		font-family: PingFang SC, PingFang SC-Heavy;
		font-weight: 700;
		color: #333333;
	}

	.topTabs {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 166rpx;
		padding: 30rpx;
		background: #ffffff;
	}

	.count {
		height: 100vh;
		width: 100%;
		padding-top: 166rpx;
		background-color: #f6f6f6;
	}
</style>